<!DOCTYPE html>
<html>
<head>
    <title>#{get 'title' /}</title>
    <meta charset="${_response_encoding}">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.css">
    <!--如果你用到了拓展包中的组件，还需要引用下面两个-->
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.css">
    <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/wxmain.css'}">
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
    <script src="/public/sui/config.js"></script>
</head>
<body>
<!-- page集合的容器，里面放多个平行的.page，其他.page作为内联页面由路由控制展示 -->
<div class="page-group">
    <!-- 单个page ,第一个.page默认被展示-->
    <div class="page">
    <header class="bar bar-nav">
        <h1 class='title'>登录</h1>
    </header>
    <div class="content">
        <div class="list-block">
            <ul>
                <!-- Text inputs -->
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-form-name"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">用户名</div>
                            <div class="item-input">
                                <input type="text" placeholder="请输入用户名" id="uname">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-form-password"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">密码</div>
                            <div class="item-input">
                                <input type="password" placeholder="请输入密码" class="" id="pwd">
                            </div>
                        </div>
                    </div>
                </li>

            </ul>
        </div>
        <div class="content-block">
            <div class="row">
                <div class="col-100"><a href="#" id="login0" class="button button-big button-fill button-success">登录</a></div>
            </div>
        </div>
    </div>
<script>
    $(function(){
        $(document).on('click','#login0',function () {
            //$.toast('操作成功，正在跳转...', 2345, 'success top');
            //$.alert('Here goes alert text');
            //return false;
            var uname = $("#uname").val();
            var pwd = $("#pwd").val();
            if(uname=='' || pwd==''){
                $.alert('用户名密码不能为空');
                return false;
            }
            $.ajax({
                type:"POST",                      //请求类型
                url:"/apicontroller/login",                 //URL
                data:{"uname":uname,"pwd":pwd},                  //传递的参数
                dataType:"json",                 //返回的数据类型
                success:function(data){          //data就是返回的json类型的数据
                    console.log(JSON.stringify(data));
                    if(data.code=="1"){
                        localStorage.setItem("_uid",uname);
                        localStorage.setItem("_pwd",pwd);
                        localStorage.setItem("user",JSON.stringify(data));
                        location.href='/WxController/index';
                    }else{
                        $.toast(data.msg, 1000, 'success top');
                    }
                },
                error:function(data){
                }
            });
            return false;
        });
        rememberUser();
    });

    if (self!=top){
        window.top.location.replace(self.location); //打开自己网站的页面
    }
    function rememberUser() {
        if(localStorage.getItem("_uid")){
            $("#uname").val(localStorage.getItem("_uid"));
        }
        if(localStorage.getItem("_pwd")){
            $("#pwd").val(localStorage.getItem("_pwd"));
        }
    }
</script>
    </div>
</div>
<script>
    $(function () {
        $.init()
    })
</script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.js' charset='utf-8'></script>
</body>
</html>